package view;

import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JButton;

import controller.GeraGrafico;

public class Tela extends JFrame {

	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JTextField jTextFieldRelevantes = null;
	private JLabel jLabelRelevantes = null;
	private JTextField jTextFieldConsulta = null;
	private JLabel jLabelPesquisa = null;
	private JButton jButtonAdicionar = null;

	GeraGrafico geraGrafico = new GeraGrafico(this);
	
	/**
	 * This method initializes 
	 * 
	 */
	public Tela() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
        this.setSize(new Dimension(535, 245));
        this.setContentPane(getJPanel());
        this.setTitle("Entre com os dados da sua consulta");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 1;
			gridBagConstraints4.gridy = 6;
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 0;
			gridBagConstraints3.gridy = 5;
			jLabelPesquisa = new JLabel();
			jLabelPesquisa.setText("Documentos Retornados:");
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.fill = GridBagConstraints.BOTH;
			gridBagConstraints2.gridy = 5;
			gridBagConstraints2.weightx = 1.0;
			gridBagConstraints2.gridx = 1;
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.gridy = 3;
			jLabelRelevantes = new JLabel();
			jLabelRelevantes.setText("Documentos relevantes:");
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
			gridBagConstraints1.gridy = 3;
			gridBagConstraints1.weightx = 1.0;
			gridBagConstraints1.gridx = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridwidth = 2;
			gridBagConstraints.gridy = 0;
			jLabel = new JLabel();
			jLabel.setText("Adicione os dados de sua pesquisa:");
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(jLabel, gridBagConstraints);
			jPanel.add(getJTextFieldRelevantes(), gridBagConstraints1);
			jPanel.add(jLabelRelevantes, gridBagConstraints11);
			jPanel.add(getJTextFieldConsulta(), gridBagConstraints2);
			jPanel.add(jLabelPesquisa, gridBagConstraints3);
			jPanel.add(getJButtonAdicionar(), gridBagConstraints4);
		}
		return jPanel;
	}

	/**
	 * This method initializes jTextFieldRelevantes	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldRelevantes() {
		if (jTextFieldRelevantes == null) {
			jTextFieldRelevantes = new JTextField();
		}
		return jTextFieldRelevantes;
	}

	/**
	 * This method initializes jTextFieldConsulta	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldConsulta() {
		if (jTextFieldConsulta == null) {
			jTextFieldConsulta = new JTextField();
		}
		return jTextFieldConsulta;
	}

	/**
	 * This method initializes jButtonAdicionar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonAdicionar() {
		if (jButtonAdicionar == null) {
			jButtonAdicionar = new JButton();
			jButtonAdicionar.setText("Adicionar Consulta");
			jButtonAdicionar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					geraGrafico.processaNovoGrafico(null, jTextFieldRelevantes.getText(), jTextFieldConsulta.getText());
				}
			});
		}
		return jButtonAdicionar;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
